<script>
	import {getQueryString} from '@/utils/utils';
	export default {
		onLaunch: function(options) {
			console.log('App Launch');
			this.findKeys();
			//const obj = wx.getEnterOptionsSync()

			
				const token = wx.getStorageSync('token');
				if (token) {
					
					const  type =uni.getStorageSync('type');
					
					if(type =='user'){
						this.$store.commit('setRole','user')
						uni.switchTab({
							url:'../plat-menu/index'
						})
						this.$API.clearCart({}).then(res => {
							if (res.code === 0) {
								this.$store.commit('setCartChooseGood',[])
								uni.$emit('updateGoodCount')
							}
						})
					}else{
						this.$store.commit('setRole','delivery')
						uni.redirectTo({
							url:'../plat-menu/delivery'
						})
					}
				} else {
					console.log('login')
					uni.navigateTo({
						url: '/pages/login/login'
					});
				}
				
		},
		onShow: function() {
			
			
		},
		onHide: function() {
			console.log('App Hide')
		},
		methods:{
			
			findKeys(){
				this.$API.getKeyNames({keys:'login_user_delivery,buttonLimit'}).then(res=>{
					res.list.forEach(item=>{
							uni.setStorageSync(item.paramKey,item.paramValue == 'false'?false:true);
					});
				})				
			

			},

		}
	}
</script>

<style>
	/*每个页面公共css */
	page {
		width: 100%;
		height: 100%;
		background: #F9F9F9;
	}
	
</style>
